package com.uglyboys;

import java.text.SimpleDateFormat;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.text.Html;
import android.text.util.Linkify;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.ImageView;
import android.widget.TextView;

import com.google.ads.AdRequest;
import com.google.ads.AdView;
import com.uglyboys.constantes.Constantes;
import com.uglyboys.control.BBBController;
import com.uglyboys.customtweetreader.model.CustomTweet;
import com.uglyboys.util.BBBSpyUtil;

public class TelaTweet extends Activity  {
	private AdView adView;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.tela_tweet);
		this.exibirTelaAdd();
		adView = (AdView)this.findViewById(R.id.adViewTweet);
		adView.loadAd(new AdRequest());
	}

	



	private void exibirTelaAdd() {
		CustomTweet tweet = BBBController.getInstance().getCustomTweet();
		TextView textConteudo = (TextView) findViewById(R.id.textoTelaTweet);
		TextView textData = (TextView) findViewById(R.id.data);
		
		textConteudo.setTextColor(Color.BLUE);
		
		String texto = BBBSpyUtil.formatarTexto(tweet.getTexto(), tweet.getUsuario());
		textConteudo.setText(Html.fromHtml(texto)); 
		textConteudo.setTextSize(Constantes.FONTE_GRANDE);
		Linkify.addLinks(textConteudo, Linkify.WEB_URLS);
		
		SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
		textData.setTextSize(Constantes.FONTE_PEQUENA);
		textData.setText(sdf.format(tweet.getDataCriacao()));

		final ImageView imageView = (ImageView) findViewById(R.id.usuarioTelaTweet);
		if(BBBController.getInstance().getImagem() != null){
			imageView.setImageDrawable(BBBController.getInstance().getImagem());
		}
	}

	  
	  @Override
		public boolean onCreateOptionsMenu(Menu menu) {
			MenuInflater inflater = getMenuInflater();
		    inflater.inflate(R.layout.menu_tela_inicial, menu);
		    return true;
		}
		
		@Override
		public boolean onOptionsItemSelected(MenuItem item) {
		    switch (item.getItemId()) {
			    case R.id.about:
		        	Intent intent = new Intent(this, About.class);
		        	startActivity(intent);
		        	break;
		    }
		    return true;
		}
 

}
